package com.example.spring.test.thread;

/**
 * Created by Administrator on 2017-8-10.
 */
public class ArmyThread implements Runnable{
    //关于volatile
    volatile boolean keepRunning = true;

    @Override
    public void run() {
        while (keepRunning){
            for(int i = 0; i < 5; i++){
                System.out.println(Thread.currentThread().getName() + " 发起了第" + "[" + i + "]次进攻");
                //让出处理器时间，下次该谁进攻还不一定
                Thread.yield();
            }
        }

    }
}
